package kaiin;

public class KaiinBeans {

	//データベース入力用変数
	private String user_id;
	private String password;
	private String simei;
	private String hurigana;
	private String seibetu;
	private String yuubin;
	private String juusyo;
	private String tel;
	private String keitai;
	private String mail;
	private String seinen;

	//フォーム出力用変数
	private String year;
	private String month;
	private String day;
	private String password2;
	private String yuubin1;
	private String yuubin2;
	private String todouhuken;
	private String juusyo1;
	private String juusyo2;

	//ログイン判定用変数
	private boolean isLogIn;

	public KaiinBeans(){
		allRemove();
	}


	public String getUser_id() {
		return user_id;
	}
	public void setUser_id(String user_id) {
		this.user_id = check(user_id);
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = check(password);
	}
	public String getSimei() {
		return simei;
	}
	public void setSimei(String simei) {
		this.simei = check(simei);
	}
	public String getHurigana() {
		return hurigana;
	}
	public void setHurigana(String hurigana) {
		this.hurigana = check(hurigana);
	}
	public String getSeibetu() {
		return seibetu;
	}
	public void setSeibetu(String seibetu) {
		this.seibetu = check(seibetu);
	}
	public String getYuubin() {
		return yuubin;
	}
	public void setYuubin(String yuubin) {
		this.yuubin = check(yuubin);
	}
	public String getJuusyo() {
		return juusyo;
	}
	public void setJuusyo(String juusyo) {
		this.juusyo = check(juusyo);
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = check(tel);
	}
	public String getKeitai() {
		return keitai;
	}
	public void setKeitai(String keitai) {
		this.keitai = check(keitai);
	}
	public String getMail() {
		return mail;
	}
	public void setMail(String mail) {
		this.mail = check(mail);
	}
	public String getSeinen() {
		return seinen;
	}
	public void setSeinen(String seinen) {
		this.seinen = check(seinen);
	}


	public String getYear() {
		return year;
	}
	public void setYear(String year) {
		year = check(year);
		if(!year.matches("[0-9]+") || year.length() != 4){
			year = "0000";
		}
		this.year = year;
	}
	public String getMonth() {
		return month;
	}
	public void setMonth(String month) {
		month = check(month);
		if(!month.matches("[0-9]+")){
			month = "00";
		}

		this.month = month;
	}
	public String getDay() {
		return day;
	}
	public void setDay(String day) {
		day = check(day);
		if(!day.matches("[0-9]+")){
			day = "00";
		}
		this.day = day;

		setSeinen(this.year, this.month, this.day);
	}
	public String getPassword2() {
		return password2;
	}
	public void setPassword2(String password2) {
		this.password2 = check(password2);
	}
	public String getYuubin1() {
		return yuubin1;
	}
	public void setYuubin1(String yuubin1) {
		this.yuubin1 = check(yuubin1);
	}
	public String getYuubin2() {
		return yuubin2;
	}
	public void setYuubin2(String yuubin2) {
		this.yuubin2 = check(yuubin2);
		setYuubin(this.yuubin1, this.yuubin2);
	}
	public String getTodouhuken() {
		return todouhuken;
	}
	public void setTodouhuken(String todouhuken) {
		this.todouhuken = check(todouhuken);
	}
	public String getJuusyo1() {
		return juusyo1;
	}
	public void setJuusyo1(String juusyo1) {
		this.juusyo1 = check(juusyo1);
	}
	public String getJuusyo2() {
		return juusyo2;
	}
	public void setJuusyo2(String juusyo2) {
		this.juusyo2 = check(juusyo2);
		setJuusyo(this.todouhuken, this.juusyo1, this.juusyo2);
	}

	//isLogIn設定用
	public boolean isLogIn() {
		return isLogIn;
	}
	public void setLogIn(boolean isLogIn) {
		this.isLogIn = isLogIn;
	}
	//nullかどうかチェックしnullだと空文字にするメソッド
	private String check(String s){
		if(s == null){
			s = "";
		}
		return s;
	}
	//生年月日を生成
	private void setSeinen(String y, String m, String d){
		this.seinen = y + m + d;
	}
	//郵便番号を生成
	private void setYuubin(String y1, String y2){
		this.yuubin = y1 + y2;
	}
	//郵便番号を生成
	private void setJuusyo(String t, String j1, String j2){
		this.juusyo = t + j1 + j2;
	}

	public void allRemove(){
		user_id = "";
		password = "";
		simei = "";
		hurigana = "";
		seibetu = "";
		yuubin = "";
		juusyo = "";
		tel = "";
		keitai = "";
		mail = "";
		seinen = "";
		year = "";
		month = "";
		day = "";
		password2 = "";
		yuubin1 = "";
		yuubin2 = "";
		todouhuken = "";
		juusyo1 = "";
		juusyo2 = "";
		isLogIn = false;
	}
}
